{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6876e5e3-2089-436a-8534-2ece20998a67",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import graphviz\n",
    "import lingam\n",
    "from lingam.utils import make_dot\n",
    "import logging\n",
    "import dowhy\n",
    "from dowhy import CausalModel\n",
    "from semopy import Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7990311d-ca3e-4d93-93fd-89299b7c64b0",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_excel(r\"\\df_korea.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23f89dac-a1ef-49d8-9aff-e9511b0f7494",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Define the SEM model\n",
    "model_desc = \"\"\"\n",
    "Social_Trust ~ Work_hours + Autonomy\n",
    "Autonomy ~ sex + marriage + age + religion + ideology + income + education \n",
    "Autonomy ~ Work_hours\n",
    "Social_Trust ~ sex + marriage + age + religion + ideology + income + education +  Work_hours\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "# Create and fit the model\n",
    "model = Model(model_desc)\n",
    "results = model.fit(df)\n",
    "\n",
    "# Inspect the model's results\n",
    "params = model.inspect()\n",
    "\n",
    "# Display the results\n",
    "print(params)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17e1d092-d0eb-4f57-a782-f6a323ec6e2e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
